/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package data;

import java.sql.*;
import java.util.Vector;
import javax.swing.text.StyledEditorKit.BoldAction;

/**
 *
 * @author RUOL
 */
public class Lop {
      private String Malop;
      private String Tenlop;
      private String Makhoa;

    public Lop() {
    }

    public Lop(String Malop, String Tenlop, String Makhoa) {
        this.Malop = Malop;
        this.Tenlop = Tenlop;
        this.Makhoa = Makhoa;
    }
    /**
     * @return the Malop
     */
    public String getMalop() {
        return Malop;
    }

    /**
     * @param Malop the Malop to set
     */
    public void setMalop(String Malop) {
        this.Malop = Malop;
    }

    /**
     * @return the Tenlop
     */
    public String getTenlop() {
        return Tenlop;
    }

    /**
     * @param Tenlop the Tenlop to set
     */
    public void setTenlop(String Tenlop) {
        this.Tenlop = Tenlop;
    }

    /**
     * @return the Makhoa
     */
    public String getMakhoa() {
        return Makhoa;
    }

    /**
     * @param Makhoa the Makhoa to set
     */
    public void setMakhoa(String Makhoa) {
        this.Makhoa = Makhoa;
    }
    
    public Vector<Lop> DanhSachLop()
    {
        Vector<Lop> dsl = new Vector<Lop>();        
        try
        {
            Connection con = ConnectToDatabase.getConnection();
            String query = "select * from Lop";
            Statement stm = con.createStatement();
            ResultSet rs = stm.executeQuery(query);
            while(rs.next())
            {
                Lop dm = new Lop();
                dm.setMalop(rs.getString("Malop"));
                dm.setTenlop(rs.getString("Tenlop"));
                dsl.add(dm);
            }
        }
        catch(Exception ex)
        {
            dsl = null;
        }
        
        return dsl;
    }
}